package org.huangxq.bigscreen.controller

import jakarta.annotation.Resource
import org.huangxq.bigscreen.service.RePortDataService
import org.slf4j.LoggerFactory
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

/**
@Description: 报表数据获取
@author: 黄显清
@Date: 2025-05-21
@version： 1.0
 */

@RestController
@RequestMapping("/data/report")
class RePortDataController {

    @Resource
    private lateinit var rePortDataService: RePortDataService

    private val log = LoggerFactory.getLogger("log")

    @RequestMapping("/getThemeName")
    fun getThemeName(code: String) = try {
        mapOf(
            "status" to 200,
            "data" to rePortDataService.getThemeName(code)
        )
    }catch(e: Exception) {
        log.error(e.message)
        mapOf(
            "status" to -1,
            "data" to e.message
        )
    }

    @RequestMapping("/getThemeData")
    fun getThemeData(code: String) = try {
        mapOf(
            "status" to 200,
            "data" to rePortDataService.getThemeData(code)
        )
    }catch(e: Exception) {
        log.error(e.message)
        mapOf(
            "status" to -1,
            "data" to e.message
        )
    }
}